import RyConfirm from './RyConfirm.vue'
import Vue from 'vue'
let instance
export default {
  install () {
    function confirm (obj) {
      // 判断是否已经创建
      if (instance) {
        document.body.removeChild(instance.vm.$el.parentNode)
      }
      const RyConfirmConstructor = Vue.extend(RyConfirm)
      instance = new RyConfirmConstructor({
        propsData: {
          ...obj
        }
      })
      instance.vm = instance.$mount()
      document.body.appendChild(instance.vm.$el)
      instance.vm.open()
    }
    Vue.prototype.$confirm = confirm
  }
}
